package com.wrh.springbootstudy.util;

import com.wrh.springbootstudy.bean.GridData;

import java.util.Random;

public class StudyHelpUtil {

    /**
     * 构建一个随机的GridData对象
     *
     * @return GridData，格点值范围 0~250
     */
    public static GridData buildGridData() {
        GridData g = new GridData();
        g.setStartX(110d)
                .setEndX(130d)
                .setStartY(60d)
                .setEndY(40d)
                .setXRes(0.05d)
                .setYRes(-0.05d);
        int yLen = (int) Math.round((g.getEndY() - g.getStartY()) / g.getYRes());
        int xLen = (int) Math.round((g.getEndX() - g.getStartX()) / g.getXRes());
        double[][] grid = new double[yLen][xLen];
        Random r = new Random();
        for (int i = 0; i < yLen; i++) {
            for (int j = 0; j < xLen; j++) {
                grid[i][j] = r.nextInt(100) / 10d;
            }
        }
        return g.setGrid(grid);
    }


}
